{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "#SVM"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "#导入必要的工具包\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "\n",
    "from sklearn.model_selection import GridSearchCV\n",
    "\n",
    "\n",
    "#评价指标用logloss\n",
    "\n",
    "from sklearn.metrics import log_loss\n",
    "\n",
    "from matplotlib import pyplot"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Pregnancies</th>\n",
       "      <th>Glucose</th>\n",
       "      <th>BloodPressure</th>\n",
       "      <th>SkinThickness</th>\n",
       "      <th>Insulin</th>\n",
       "      <th>BMI</th>\n",
       "      <th>DiabetesPedigreeFunction</th>\n",
       "      <th>Age</th>\n",
       "      <th>Outcome</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>6</td>\n",
       "      <td>148.0</td>\n",
       "      <td>72.0</td>\n",
       "      <td>35.00000</td>\n",
       "      <td>155.548223</td>\n",
       "      <td>33.6</td>\n",
       "      <td>0.627</td>\n",
       "      <td>50</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>1</td>\n",
       "      <td>85.0</td>\n",
       "      <td>66.0</td>\n",
       "      <td>29.00000</td>\n",
       "      <td>155.548223</td>\n",
       "      <td>26.6</td>\n",
       "      <td>0.351</td>\n",
       "      <td>31</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>8</td>\n",
       "      <td>183.0</td>\n",
       "      <td>64.0</td>\n",
       "      <td>29.15342</td>\n",
       "      <td>155.548223</td>\n",
       "      <td>23.3</td>\n",
       "      <td>0.672</td>\n",
       "      <td>32</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>1</td>\n",
       "      <td>89.0</td>\n",
       "      <td>66.0</td>\n",
       "      <td>23.00000</td>\n",
       "      <td>94.000000</td>\n",
       "      <td>28.1</td>\n",
       "      <td>0.167</td>\n",
       "      <td>21</td>\n",
       "      <td>0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0</td>\n",
       "      <td>137.0</td>\n",
       "      <td>40.0</td>\n",
       "      <td>35.00000</td>\n",
       "      <td>168.000000</td>\n",
       "      <td>43.1</td>\n",
       "      <td>2.288</td>\n",
       "      <td>33</td>\n",
       "      <td>1</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   Pregnancies  Glucose  BloodPressure  SkinThickness     Insulin   BMI  \\\n",
       "0            6    148.0           72.0       35.00000  155.548223  33.6   \n",
       "1            1     85.0           66.0       29.00000  155.548223  26.6   \n",
       "2            8    183.0           64.0       29.15342  155.548223  23.3   \n",
       "3            1     89.0           66.0       23.00000   94.000000  28.1   \n",
       "4            0    137.0           40.0       35.00000  168.000000  43.1   \n",
       "\n",
       "   DiabetesPedigreeFunction  Age  Outcome  \n",
       "0                     0.627   50        1  \n",
       "1                     0.351   31        0  \n",
       "2                     0.672   32        1  \n",
       "3                     0.167   21        0  \n",
       "4                     2.288   33        1  "
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#把数据读进来，因为和Logistics的数据一样，读进去后直接标准化训练数据。\n",
    "train = pd.read_csv(\"FE_diabetes.csv\")\n",
    "train.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "#设置输入的X值和输出的Y值\n",
    "y_train = train ['Outcome']\n",
    "x_train = train.drop([\"Outcome\"],axis = 1)\n",
    "\n",
    "\n",
    "#对数据进行标准化处理\n",
    "from sklearn.preprocessing import StandardScaler\n",
    "\n",
    "ss_x = StandardScaler()\n",
    "\n",
    "x_train = ss_x.fit_transform(x_train)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.7669270833333334\n",
      "{'C': 0.4}\n"
     ]
    }
   ],
   "source": [
    "#模型训练(线性的SVM)\n",
    "from sklearn.svm import SVC\n",
    "from sklearn.model_selection import GridSearchCV\n",
    "\n",
    "penaltys = ['l1','l2']\n",
    "Cs = [ 0.01, 0.1, 0.2, 0.22, 0.24, 0.26, 0.28, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1]\n",
    "param_grid = {'C': Cs }\n",
    "\n",
    "\n",
    "grid = GridSearchCV(SVC(kernel = 'linear'), param_grid, cv = 5)\n",
    "grid.fit(x_train, y_train)\n",
    "\n",
    "print(grid.best_score_)\n",
    "print(grid.best_params_)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "GridSearchCV(cv=5, error_score='raise',\n",
       "       estimator=SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0,\n",
       "  decision_function_shape='ovr', degree=3, gamma='auto', kernel='linear',\n",
       "  max_iter=-1, probability=False, random_state=None, shrinking=True,\n",
       "  tol=0.001, verbose=False),\n",
       "       fit_params=None, iid=True, n_jobs=1,\n",
       "       param_grid={'C': [0.01, 0.1, 0.2, 0.22, 0.24, 0.26, 0.28, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1], 'gamma': [0.0001, 0.0002, 0.0003, 0.0004, 0.0005]},\n",
       "       pre_dispatch='2*n_jobs', refit=True, return_train_score='warn',\n",
       "       scoring=None, verbose=0)"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#模型训练（RBF核）\n",
    "from sklearn.svm import SVC\n",
    "from sklearn.model_selection import GridSearchCV\n",
    "\n",
    "Cs = [ 0.01, 0.1, 0.2, 0.22, 0.24, 0.26, 0.28, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1]\n",
    "gammas = [0.0001,0.0002,0.0003,0.0004,0.0005]\n",
    "\n",
    "param_grid = {'C': Cs, 'gamma': gammas}\n",
    "grid = GridSearchCV(SVC(kernel = 'linear'), param_grid, cv = 5)\n",
    "\n",
    "grid.fit(x_train, y_train)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "D:\\AI\\Anaconda3\\lib\\site-packages\\sklearn\\utils\\deprecation.py:122: FutureWarning: You are accessing a training score ('mean_train_score'), which will not be available by default any more in 0.21. If you need training scores, please set return_train_score=True\n",
      "  warnings.warn(*warn_args, **warn_kwargs)\n",
      "D:\\AI\\Anaconda3\\lib\\site-packages\\sklearn\\utils\\deprecation.py:122: FutureWarning: You are accessing a training score ('std_train_score'), which will not be available by default any more in 0.21. If you need training scores, please set return_train_score=True\n",
      "  warnings.warn(*warn_args, **warn_kwargs)\n",
      "No handles with labels found to put in legend.\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.7669270833333334\n",
      "{'C': 0.4, 'gamma': 0.0001}\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYsAAAEKCAYAAADjDHn2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IiPaNkISIikZQsREQkkpKFiIhEUrIQEZFIShYi3WBm9ae5/WNhT2TMLNfM/s3MdoWjl64ys0vNLDN8Peg6zcqZS8lCpI+Y2QUEo35WhEX/TtDTdoq7XwB8gWD03iaC5/s/k3BHIv1AyUKkByzwQzPbYsFcHp8Jy4eY2Y/ClsJTZrbMzNp7Gd9B2BvYzM4BLiUYKqINguEs3P3psO6TYX2RAUHNXJGe+QQwE7gIGAGsM7NVBMNRTCQYjG8kwdDoD4XbzOP9oTQuADa6e2sn+98CXJKSyEV6QC0LkZ6ZDzzs7q0eDEz4IsGX+3zgUXdvc/d3CcYvajcGqEpm52ESaWofd0ukvylZiPRMouGfuyoHaCAYxweCcbQuMrOu/g9mAY09iE2k1ylZiPTMKuAzZpZmZsXAAoJB3FYDnwzvXYwCro7bZjtwLoC77wLKgL8JRyfFzKaY2c3h6yKgyuOGChfpT0oWIj2zhGDU2k0Eo4z+t/Cy0+MEI89uAf6NYHa+o+E2T/PB5PElggl4ysMJfX7C+/MNLASWpfYjiCRPo86K9DIzy3X3+rB18BrBTILvmlk2wT2MeV3c2G7fxxPAN/305kAX6TV6Gkqk9z1lZvkE02p+L2xx4O4NZvZdgnmQ3+ls43CSmyeVKGQgUctCREQi6Z6FiIhEUrIQEZFIShYiIhJJyUJERCIpWYiISCQlCxERifT/AdxyQxYqBliQAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#把最佳结果的参数和曲线打印出来。\n",
    "print(grid.best_score_)\n",
    "print(grid.best_params_)\n",
    "\n",
    "test_means = grid.cv_results_[ 'mean_test_score' ]\n",
    "test_stds = grid.cv_results_[ 'std_test_score' ]\n",
    "train_means = grid.cv_results_[ 'mean_train_score' ]\n",
    "train_stds = grid.cv_results_[ 'std_train_score' ]\n",
    "\n",
    "\n",
    "n_Cs = len(Cs)\n",
    "number_gamms = len(gammas)\n",
    "test_scores = np.array(test_means).reshape(n_Cs,number_gamms)\n",
    "train_scores = np.array(train_means).reshape(n_Cs,number_gamms)\n",
    "test_stds = np.array(test_stds).reshape(n_Cs,number_gamms)\n",
    "train_stds = np.array(train_stds).reshape(n_Cs,number_gamms)\n",
    "\n",
    "\n",
    "x_axis = np.log10(Cs)\n",
    "for i, value in enumerate(gammas):\n",
    "    pyplot.errorbar(x_axis, test_scores[:,i], yerr = test_stds[:,i])\n",
    "    pyplot.errorbar(x_axis, train_scores[:,i], yerr = train_stds[:,i])\n",
    "\n",
    "pyplot.legend()\n",
    "pyplot.xlabel( 'log(C)' )\n",
    "pyplot.ylabel( 'aocuary' )\n",
    "pyplot.savefig( 'LogisticGridSearchCV_C.png' )\n",
    "pyplot.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "#总结：S\n",
    "#SVM的线性和RBF核的性能一样\n",
    "#Logistic的正确率比SVM的稍微要好一丢丢。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
